<template>
	<view class="unitDetails">
		<view class="unitDetails-header" :style="tabberStyle">
			<view class="ff-bg-blue">
				<image class="unitDetails-header-bg"
					src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/compang-details-bg.png"
					mode="">
				</image>
				<view class="unitDetails-header-content ff-bg-fff ff-border-radius-10">
					<view class="ff-font-16 ff-font-weight-600 ff-margin-bottom-8 ff-line-height-1-3">
						{{unitHeaderDetailsInfo.companyName}}
					</view>
					<view class="unitDetails-header-content-box-tips ff-margin-bottom-8">
						<view class="ff-align-items-one ff-font-12 ff-color-fff">
							<view>
								<view class="tips1" v-if="unitHeaderDetailsInfo.companyType == 1">消防安全重点单位</view>
								<view class="tips2" v-if="unitHeaderDetailsInfo.companyType == 2">一般单位</view>
								<view class="tips3" v-if="unitHeaderDetailsInfo.companyType == 3">火灾高危单位</view>
								<view class="tips3" v-if="unitHeaderDetailsInfo.companyType == 4">有消防设施的社区</view>
								<view class="tips3" v-if="unitHeaderDetailsInfo.companyType == 5">其他</view>
							</view>
							<view class="ff-margin-left-10">
								<view class="tips4" v-if="unitHeaderDetailsInfo.isOnline == 0">未上线</view>
								<view class="tips5" v-if="unitHeaderDetailsInfo.isOnline == 1">已上线</view>
							</view>
						</view>
					</view>
					<view class="ff-color-5C5F65 ff-font-13">
						<view class="ff-margin-bottom-8">统一社会信用代码：{{unitHeaderDetailsInfo.organizationCode}}</view>
						<view>已维保次数：{{unitHeaderDetailsInfo.maintenanceNum}}次</view>
					</view>
				</view>
				<view class="unitDetails-content">
					<view class="unitDetails-content-tabs ff-bg-fff">
						<u-sticky offset-top="0">
							<view class="unitDetails-content-tabs-box ff-bg-fff ff-padding-bottom-10">
								<u-tabs :list="tabsList" :is-scroll="false" :current="currentIndex"
									@change="changeTabs"></u-tabs>
							</view>
							<view v-if="currentIndex == 1"
								class="ff-flex-between ff-bg-f5 ff-align-items-one ff-padding-15">
								<view class="">共有<text class="ff-color-blue">{{totalProject}}个</text>项目</view>
								<u-search placeholder="请输入项目名称" bg-color="#ffffff" :show-action="fasle" height="80"
									input-align="center" @change="maintenanceProjectChange"
									v-model="params.projectName"></u-search>
							</view>
							<view v-if="currentIndex == 2">
								<view class="ff-flex-between ff-bg-f5 ff-align-items-one ff-padding-15">
									<view class="">共有<text class="ff-color-blue">{{totalReport}}份</text>报告</view>
									<u-search placeholder="请输入项目名称" bg-color="#ffffff" :show-action="fasle" height="80"
										input-align="center" @change="reportChange"
										v-model="params.projectName"></u-search>
								</view>
							</view>
						</u-sticky>
					</view>
					<view class="ff-bg-f5">
						<view v-if="currentIndex == 0" class="ff-margin-12 ff-bg-fff ff-padding-15 ff-border-radius-10">
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">隶属救援机构</view>
								<view>{{unitBasicDetailsInfo.departmentName || '--'}}</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999 title">注册单位地址</view>
								<view class="ff-text-right ff-flex-1 ff-line-height-1-3">
									{{unitBasicDetailsInfo.companyAddr || '--'}}
								</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999 title">实际办公地址</view>
								<view class="ff-text-right ff-flex-1 ff-line-height-1-3">
									{{unitBasicDetailsInfo.officeAddr || '--'}}
								</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">消防安全管理人姓名</view>
								<view class="">{{unitBasicDetailsInfo.fireManageName || '--'}}</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">消防安全管理人手机号</view>
								<view class="">{{unitBasicDetailsInfo.fireManagePhone || '--'}}</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">消防安全责任人姓名</view>
								<view class="">{{unitBasicDetailsInfo.fireDutyName || '--'}}</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">消防安全责任人手机号</view>
								<view class="">{{unitBasicDetailsInfo.fireDutyPhone || '--'}}</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">员工数量</view>
								<view class="">{{unitBasicDetailsInfo.staffNum || '--'}}人</view>
							</view>
							<view class="ff-flex-between ff-padding-bottom-20">
								<view class="ff-color-999">注册时间</view>
								<view class="">{{unitBasicDetailsInfo.created || '--'}}</view>
							</view>
							<view class="ff-flex-between">
								<view class="ff-color-999">上线时间</view>
								<view class="">{{unitBasicDetailsInfo.onlineTime || '--'}}</view>
							</view>
						</view>
						<view v-if="currentIndex == 1">
							<view v-if="maintenanceProjectList">
								<view v-if="maintenanceProjectList.length > 0">
									<view v-for="(item, index) of maintenanceProjectList" :key="index"
										@click.stop="maintenanceProjectClick(item)"
										class="ff-margin-left-12 ff-margin-right-12 ff-margin-bottom-12 ff-bg-fff ff-padding-15 ff-border-radius-10 ff-relative">
										<view
											class="ff-font-16 ff-font-weight-600 ff-line-height-1-3 ff-margin-bottom-12">
											{{item.projectName||'--'}}
										</view>
										<view class="ff-color-5C5F65">
											<view class="ff-margin-bottom-8">
												技术服务机构：{{item.orgName||'--'}}
											</view>
											<view class="ff-margin-bottom-8">合同编号：{{item.projectCode ||'--'}}
											</view>
											<view class="ff-margin-bottom-8">
												起止日期：{{item.maintenanceStartTime == null ? '' : item.maintenanceStartTime.substr(0, 10)}}--{{item.maintenanceEndTime == null ? '--' : item.maintenanceEndTime.substr(0, 10)}}
											</view>
											<view class="ff-margin-bottom-8">已维保次数：{{item.maintenanceInfoNum || '0'}}次
											</view>
											<view>签章完成报告书：{{item.reportSignedNum || '0'}}份</view>
										</view>
										<view class="imgIconList">
											<image v-if="item.status == 6"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/super-state1.png"
												alt=""></image>
											<image v-if="item.status == 5"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate2.png"
												alt=""></image>
											<image v-if="item.status == 4"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate3.png"
												alt=""></image>
											<image v-if="item.status == 3"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate4.png"
												alt=""></image>
											<image v-if="item.status == 1"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate5.png"
												alt=""></image>
											<image v-if="item.status == 0"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate6.png"
												alt=""></image>
											<image v-if="item.status == 2"
												src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/superstate7.png"
												alt=""></image>
										</view>
									</view>
									<u-divider v-if="noData" border-color="#909399" height="120" margin-bottom="30"
										color="#909399" bg-color="#f5f5f5">没有更多了</u-divider>
								</view>
								<f-noData v-else topStyle="50%"></f-noData>
							</view>
						</view>
						<view v-if="currentIndex == 2">
							<view v-if="reportList">
								<view v-if="reportList.length > 0">
									<view v-for="(item, index) of reportList" :key="index"
										class="report-content-box ff-relative ff-margin-12 ff-bg-fff ff-border-radius-10">
										<view class="ff-padding-12">
											<view class="ff-flex">
												<image class="pdfImg"
													src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/pdf.png"
													alt=""></image>
												<view
													class="ff-font-16 ff-font-weight-600 ff-line-height-1-3 ff-margin-bottom-12">
													{{item.projectName}}<text v-if="item.rank">第{{item.rank}}次维保</text>
												</view>
											</view>
											<view class="ff-flex ff-align-items-1 ff-padding-left-10">
												<view class="report-content-box-tipsList ff-font-12">
													<view class="tipsList tipsList1" v-if="item.maintenanceType == 1">月检
													</view>
													<view class="tipsList tipsList1" v-if="item.maintenanceType == 2">季检
													</view>
													<view class="tipsList tipsList1" v-if="item.maintenanceType == 3">
														半年检
													</view>
													<view class="tipsList tipsList1" v-if="item.maintenanceType == 4">年检
													</view>
													<view class="tipsList tipsList1" v-if="item.maintenanceType == 5">
														特殊检
													</view>
												</view>
												<view class="report-content-box-tipsList ff-font-12">
													<view class="tipsList tipsList2" v-if="item.signStatus == 1">签章中
													</view>
													<view class="tipsList tipsList3" v-else-if="item.signStatus == 2">
														签章完成
													</view>
													<view class="tipsList tipsList4" v-else>未签章
													</view>
												</view>
											</view>
											<view class="ff-color-5C5F65">
												<view class="ff-margin-bottom-8">技术服务机构：{{item.orgName ||'--'}}</view>
												<view class="ff-margin-bottom-8">
													报告签发时间：{{item.maintenanceTime == null ? '--' : item.maintenanceTime}}
												</view>
												<view>签章完成时间：{{item.signTime ||'--'}}</view>
											</view>

										</view>
										<view class="ff-flex report-content-butList">
											<view @click="signatureClick(item)" class="ff-flex ff-align-items-1">
												<image
													src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/signatureIcon.png"
													mode=""></image>
												<view>签章情况</view>
											</view>
											<view @click="maintenanceReportClick(item)"
												class="ff-flex ff-align-items-1">
												<image
													src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/reportIcon.png"
													mode=""></image>
												<view>维保报告书</view>
											</view>
										</view>
									</view>
									<u-divider v-if="noData" border-color="#909399" height="120" margin-bottom="30"
										color="#909399" bg-color="#f5f5f5">没有更多了</u-divider>
								</view>
								<f-noData v-else topStyle="50%"></f-noData>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view @click="updateDataClick" class="unitDetails-btn">
			<view class="unitDetails-btn-box">
				<view class="ff-padding-3">
					<view class="ff-margin-bottom-5 ff-font-15">更新本单位数据</view>
					<view class="ff-font-13 ff-color-B8DDFF">
						更新时间：{{superviseCompanySyncLogInfo.latestValidEndTime || '--'}}
					</view>
				</view>
			</view>
		</view>
		<!-- 签章情况弹窗 -->
		<u-popup v-model="signatureState" mode="bottom" closeable height="85%" safe-area-inset-bottom="true"
			border-radius="40" close-icon-color="#fff" @close="signatureState = false">
			<view class="signatureBox ff-bg-f5">
				<view class="signatureBox-title ff-padding-15 ff-font-15 ff-bg-blue ff-color-fff ff-text-center">签章情况
				</view>
				<view class="signatureBox-content">
					<view v-for="(item, index) of signatureList" :key="index"
						class="ff-margin-12 ff-padding-12 ff-align-items-1 ff-bg-fff ff-border-radius-10 ff-flex ff-flex-between">
						<view class="ff-flex ff-align-items-1">
							<image
								src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/fire-technology/peopleIcon.png"
								mode=""></image>
							<view class="ff-margin-left-12">
								<view class="ff-margin-bottom-8 ff-font-15">
									{{item.username}}
									<text class="ff-color-999 ff-font-13 ff-margin-left-5">{{item.userTypeName}}</text>
								</view>
								<view class="ff-font-13 ff-color-555 ff-line-height-1-3" style="width: 300rpx;">
									{{item.sealTypeName}}
								</view>
							</view>
						</view>
						<view class="report-content-box-tips ff-font-12">
							<view class="tipsList tipsList4" v-if="item.signStatus == 0">未签章</view>
							<view class="tipsList tipsList2" v-if="item.signStatus == 1">签章中</view>
							<view class="tipsList tipsList3" v-if="item.signStatus == 2">签章完成</view>
						</view>
					</view>
				</view>
			</view>
		</u-popup>
		<u-back-top :scrollTop="scrollTopList.scrollTop" top="200" mode="circle" :iconStyle="scrollTopList.iconStyle"
			:customStyle="scrollTopList.customstyle"></u-back-top>
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
	</view>
</template>

<script>
	import config from "@/tools/config.js";
	export default {
		data() {
			return {
				// 返回顶部icon
				scrollTopList: {
					scrollTop: 0,
					iconStyle: {
						fontSize: '32rpx',
						color: '#FFFFFF'
					},
					customstyle: {
						background: '#3B83FE'
					}
				},
				unitHeaderDetailsInfo: {}, // 单位头部详情
				unitBasicDetailsInfo: {}, // 单位头部详情
				tabsList: [{
					name: '单位基本信息'
				}, {
					name: '维保项目'
				}, {
					name: '维保报告书'
				}],
				currentIndex: 0,
				totalProject: '', // 维保项目总数
				totalReport: '', // 报告书总数
				maintenanceProjectList: [], // 维保项目数据列表
				reportList: [], // 维保项目数据列表
				params: {
					companyId: '',
					current: 1,
					size: 10,
					projectName: "", // 项目名字
				},
				noData: false, // 没有更多了
				signatureList: [], // 签章状态列表数据
				signatureState: false, // 签章情况弹窗显/隐
				superviseCompanySyncLogInfo: {}, // 监管信息
				timeSupervise: null, // 定时器
			}
		},
		// 页面滚动距离顶部的数据
		onPageScroll(e) {
			this.scrollTopList.scrollTop = e.scrollTop;
		},
		onLoad(e) {
			// console.log('前边传过来的参数：', e)
			this.params.companyId = e.id
			this.getUnitHeaderDetails(e.id) // 获取单位详情页头部的数据
			this.getUnitContentDetails(e.id) // 获取单位详情页的基本数据
			this.getSuperviseCompanySyncLog(e.id) // 获取监管查看单位数据处理
			clearInterval(this.timeSupervise) // 停止定时任务
		},
		// 上拉加载
		onReachBottom() {
			if (!this.noData) {
				this.params.current++;
				if (this.currentIndex == 1) {
					this.getMaintenanceProjectList() // 获取维保项目的数据
				} else if (this.currentIndex == 2) {
					this.getReportList() // 获取报告书的数据
				}
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			let that = this;
			that.params.current = 1;
			that.getSuperviseCompanySyncLog() // 获取监管查看单位数据处理
			if (this.currentIndex == 1) {
				this.getMaintenanceProjectList() // 获取维保项目的数据
			} else if (this.currentIndex == 2) {
				this.getReportList() // 获取报告书的数据
			}
			setTimeout(() => {
				that.$refs.uToast.show({
					title: '刷新成功',
					type: 'success'
				});
				uni.stopPullDownRefresh(); // 停止刷新
			}, 100);
		},
		onUnload() {
			clearInterval(this.timeSupervise) // 停止定时任务
		},
		methods: {
			// 获取监管查看单位数据处理
			async getSuperviseCompanySyncLog(id) {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.post({
					url: `/supervise/superviseCompanySyncLog/${id}`
				})
				// console.log('获取监管查看单位数据处理', data)
				this.$refs.loading.closeLoading(); // 关闭loading动画
				if (data.code == 200) {
					this.superviseCompanySyncLogInfo = data.data
				} else {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 获取监管查看单位数据处理1
			async getSuperviseCompanySyncLog1(id) {
				let that = this
				that.$refs.loading.openLoading('更新中···'); // 打开loading动画
				const data = await that.$http.post({
					url: `/supervise/superviseCompanySyncLog/${id}`
				})
				// console.log('获取监管查看单位数据处理', data)
				if (data.code == 200) {
					if (data.data.status != 1) {
						that.$refs.uToast.show({
							title: data.msg,
							type: 'success'
						});
						that.$refs.loading.closeLoading(); // 关闭loading动画
						clearInterval(that.timeSupervise)
						that.superviseCompanySyncLogInfo = data.data
						that.getUnitHeaderDetails(that.params
							.companyId) // 获取单位详情页头部的数据
						that.params.current = 1;
						if (that.currentIndex == 0) {
							that.getUnitHeaderDetails(that.params
								.companyId) // 获取单位详情页头部的数据
							that.getUnitContentDetails(that.params
								.companyId) // 获取单位详情页的基本数据
						} else if (that.currentIndex == 1) {
							that.getMaintenanceProjectList() // 获取维保项目的数据
						} else if (that.currentIndex == 2) {
							that.getReportList() // 获取报告书的数据
						}
					}
				} else {
					that.$refs.loading.closeLoading(); // 关闭loading动画
					that.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 点击监管获取最新一次数据
			async updateDataClick() {
				let that = this
				uni.showModal({
					title: '',
					content: '即将更新本单位的数据，耗时可能较长，请确认是否更新？',
					confirmColor: '#3178FF',
					showCancel: true,
					confirmText: '确认更新',
					cancelText: '取消',
					success: function(res) {
						if (res.confirm) {
							that.$refs.loading.openLoading('更新中···'); // 打开loading动画
							that.$http.post({
								url: `/supervise/superviseSubmitCompanySync/${that.params.companyId}`
							}).then(data => {
								// console.log('获取监管查看单位数据处理', data)
								// that.$refs.loading.closeLoading(); // 关闭loading动画
								if (data.code == 200) {
									that.timeSupervise = setInterval(() => {
										that.getSuperviseCompanySyncLog1(that.params
											.companyId) // 获取监管查看单位数据处理
									}, 1000)
									// 30秒后自动停止
									setTimeout(() => {
										that.$refs.loading.closeLoading();
										clearInterval(that.timeSupervise)
									}, 30000)
								} else {
									that.$refs.loading.closeLoading();
									that.$refs.uToast.show({
										title: data.msg,
										type: 'error'
									});
								}
							})
						}
					},
				})
			},
			// 获取详情页头部的数据
			async getUnitHeaderDetails(id) {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.get({
					url: `/supervise/superviseCompanySingle/${id}`
				})
				// console.log('获取详情页头部的数据', data)
				this.$refs.loading.closeLoading(); // 关闭loading动画
				if (data.code == 200) {
					this.unitHeaderDetailsInfo = data.data
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 切换tabs
			changeTabs(e) {
				this.currentIndex = e
				this.params.current = 1;
				this.params.projectName = ''
				if (e == 0) {
					this.getUnitHeaderDetails(this.params.companyId) // 获取单位详情页头部的数据
					this.getUnitContentDetails(this.params.companyId) // 获取单位详情页的基本数据
				} else if (e == 1) {
					this.getMaintenanceProjectList() // 获取维保项目的数据
				} else if (e == 2) {
					this.getReportList() // 获取报告书的数据
				}
			},
			// 获取单位详情页的基本数据
			async getUnitContentDetails(id) {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.get({
					url: `/supervise/superviseCompanyBase/${id}`
				})
				// console.log('获取单位基本详情页的基本数据', data)
				this.$refs.loading.closeLoading(); // 关闭loading动画
				if (data.code == 200) {
					this.unitBasicDetailsInfo = data.data
				} else {
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 搜索项目
			maintenanceProjectChange() {
				this.params.current = 1;
				this.getMaintenanceProjectList(); // 获取维保项目的数据
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
			},
			// 获取维保项目的数据
			async getMaintenanceProjectList() {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.post({
					url: '/supervise/superviseCompanyProjectPage',
					data: this.params
				});
				// console.log('获取维保项目的数据------', data);
				if (data.code == 200) {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.totalProject = data.data.total
					const infoList = data.data.records;
					if (infoList.length == 0 && this.params.current == 1) {
						// console.log('首次加载没数据');
						this.noData = false;
						this.maintenanceProjectList = [];
					} else if (infoList.length < 5 && this.params.current == 1) {
						this.noData = true;
						this.maintenanceProjectList = infoList;
					} else if (infoList.length !== 0 && this.params.current == 1) {
						// console.log('首次加载有数据');
						this.noData = false;
						this.maintenanceProjectList = infoList;
					} else if (infoList.length !== 0 && this.params.current > 1) {
						// console.log('上拉加载更多数据');
						this.noData = false;
						this.maintenanceProjectList = this.maintenanceProjectList.concat(infoList);
					} else if (infoList.length == 0 && this.params.current > 1) {
						// console.log('上拉加载没有更多数据了');
						this.noData = true;
					}
				} else {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 搜索报告书
			reportChange() {
				this.params.current = 1;
				this.getReportList(); // 获取报告书的数据
			},
			// 获取报告书的数据
			async getReportList() {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.post({
					url: '/supervise/superviseCompanySignReportPage',
					data: this.params
				});
				// console.log('获取报告书的数据------', data);
				if (data.code == 200) {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.totalReport = data.data.total
					const infoList = data.data.records;
					if (infoList.length == 0 && this.params.current == 1) {
						// console.log('首次加载没数据');
						this.noData = false;
						this.reportList = [];
					} else if (infoList.length < 5 && this.params.current == 1) {
						this.noData = true;
						this.reportList = infoList;
					} else if (infoList.length !== 0 && this.params.current == 1) {
						// console.log('首次加载有数据');
						this.noData = false;
						this.reportList = infoList;
					} else if (infoList.length !== 0 && this.params.current > 1) {
						// console.log('上拉加载更多数据');
						this.noData = false;
						this.reportList = this.reportList.concat(infoList);
					} else if (infoList.length == 0 && this.params.current > 1) {
						// console.log('上拉加载没有更多数据了');
						this.noData = true;
					}
				} else {
					this.$refs.loading.closeLoading(); // 关闭loading动画
					this.$refs.uToast.show({
						title: data.msg,
						type: 'error'
					});
				}
			},
			// 点击进入报告书详情页
			maintenanceProjectClick(item) {
				this.$pageJump.navigateTo('/pages/supervise/unit/components/reportList?id=' + item.projectId)
			},
			// 查询签章状态
			async signatureClick(item) {
				// console.log('item', item)
				this.$refs.loading.openLoading('获取中···'); // 打开loading动画
				const data = await this.$http.get({
					url: `/supervise/signList/${item.maintenanceId}`
				})
				// console.log('获取当前点击的签章状态', data)
				this.$refs.loading.closeLoading(); // 关闭loading动画
				if (data.code == 200) {
					this.signatureState = true
					this.signatureList = data.data
				} else {
					this.signatureState = false
					uni.showModal({
						title: '温馨提示',
						content: data.msg,
						confirmColor: '#3178FF',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {}
						},
					})
				}
			},
			// 查看维保报告书
			maintenanceReportClick(item) {
				// console.log('查看维保报告书', item)
				let that = this
				if (item.signStatus == 1) {
					that.$refs.loading.openLoading('报告书加载中···');
					uni.request({
						url: `${config.baseUrl}/supervise/previewSignFile/${item.ydtFileId}`,
						method: 'get',
						responseType: 'arraybuffer', //  小程序不支持bolb
						success: res => {
							that.$refs.loading.closeLoading();
							const fs = uni.getFileSystemManager()
							const filePath = wx.env.USER_DATA_PATH + '/' + Date.now() +
								'.pdf' // wx.env.USER_DATA_PATH 为微信提供的保存文件路径
							fs.writeFile({
								filePath,
								data: res
									.data, // 如果是字符串 uni.base64ToArrayBuffer(data.data.replace(/[\r\n]/g, ''))  // 将 base64 转为 arrayuffer
								success() {
									uni.openDocument({
										showMenu: true,
										fileType: 'pdf',
										filePath,
										success: function() {
											// console.log('打开文档成功')
										}
									})
								},
								fail(err) {
									// console.log('错误', err)
								}
							})
						},
						fail() {
							that.$refs.loading.closeLoading();
							that.$refs.uToast.show({
								title: '报告书发生错误，请重新打开',
								type: 'error'
							});
						}
					})
				} else if (item.signStatus == 2 && item.reportSignUrl) {
					that.$refs.loading.openLoading('报告书加载中···');
					uni.downloadFile({
						url: item.reportSignUrl,
						success(res) {
							// console.log(res)
							let filePath = res.tempFilePath;
							uni.openDocument({
								filePath: filePath,
								showMenu: true,
								success() {
									// console.log('打开文档成功', res);
									that.$refs.loading.closeLoading();
								},
								fail() {
									that.$refs.loading.closeLoading();
									that.$refs.uToast.show({
										title: '报告书发生错误，请重新打开',
										type: 'error'
									});
								}
							});
						},
						fail() {
							that.$refs.uToast.show({
								title: '报告书发生错误，请重新打开',
								type: 'error'
							});
							that.$refs.loading.closeLoading();
						}
					});
				} else if (item.signStatus == 3 && item.reportUrl) {
					that.$refs.loading.openLoading('报告书加载中···');
					uni.downloadFile({
						url: item.reportUrl,
						success(res) {
							// console.log(res)
							let filePath = res.tempFilePath;
							uni.openDocument({
								filePath: filePath,
								showMenu: true,
								success() {
									// console.log('打开文档成功', res);
									that.$refs.loading.closeLoading();
								},
								fail() {
									that.$refs.loading.closeLoading();
									that.$refs.uToast.show({
										title: '报告书发生错误，请重新打开',
										type: 'error'
									});
								}
							});
						},
						fail() {
							that.$refs.uToast.show({
								title: '报告书发生错误，请重新打开',
								type: 'error'
							});
							that.$refs.loading.closeLoading();
						}
					});
				} else {
					uni.showModal({
						title: '温馨提示',
						content: '暂无已签章的报告书',
						confirmColor: '#3178FF',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {}
						},
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.activePadding {
		padding: 30rpx 0rpx 0rpx;
	}

	.unitDetails {
		&-header {

			.ff-bg-blue {
				height: 350rpx;
			}

			&-bg {
				width: 100%;
				height: 350rpx;
			}

			&-content {
				position: relative;
				// z-index: 99;
				margin: -330rpx 24rpx 20rpx;
				padding: 24rpx 30rpx;

				&-box {
					&-tips {

						.tips1 {
							background-color: #F50000;
							padding: 12rpx 15rpx;
							border-top-right-radius: 25rpx;
							border-bottom-right-radius: 25rpx;
							border-bottom-left-radius: 24rpx;
						}

						.tips2 {
							background-color: #FF9918;
							padding: 12rpx 15rpx;
							border-top-right-radius: 25rpx;
							border-bottom-right-radius: 25rpx;
							border-bottom-left-radius: 24rpx;
						}

						.tips3 {
							background-color: #2B68FF;
							padding: 12rpx 15rpx;
							border-top-right-radius: 25rpx;
							border-bottom-right-radius: 25rpx;
							border-bottom-left-radius: 24rpx;
						}

						.tips4 {
							border: 2rpx solid #9B9B9B;
							background-color: #F8F8F8;
							padding: 12rpx 15rpx;
							color: #9B9B9B;
							border-radius: 10rpx;
						}

						.tips5 {
							border: 2rpx solid #0BCB74;
							background-color: #ECFFF6;
							padding: 12rpx 15rpx;
							color: #0BCB74;
							border-radius: 10rpx;
						}
					}

					&-tipsList {}
				}
			}
		}

		&-content {
			padding-bottom: 200rpx;

			&-tabs {
				border-top-left-radius: 20rpx;
				border-top-right-radius: 20rpx;
				padding: 30rpx 0rpx 0rpx;

				&-box {
					overflow: hidden;
				}
			}

			.title {
				width: 210rpx;
			}
		}
	}

	.report-top-tips {
		background: #f5f5f5;
		padding: 0 24rpx;

		&-box {
			background: linear-gradient(to right, #FDEEE1, #FCF6F1);
			border-radius: 30rpx;
			color: #FE9025;
		}


	}

	.report-content-box-tips {
		.tips1 {
			position: absolute;
			right: 4%;
			top: 20%;
			background-color: #ecf5ff;
			color: #2979ff;
			border-radius: 11rpx;
			display: inline-block;
			padding: 13rpx 30rpx;
		}
	}

	.pdfImg {
		width: 35rpx;
		height: 35rpx;
		margin-right: 10rpx;
	}

	.imgIconList {
		image {
			width: 135rpx;
			height: 110rpx;
			position: absolute;
			right: 2%;
			top: 30%;
		}
	}

	.tipsList {
		border-radius: 11rpx;
		display: inline-block;
		padding: 13rpx 30rpx;
		margin: 0 0rpx 25rpx 15rpx;
	}

	.tipsList1 {
		background-color: #ecf5ff;
		color: #2979ff;
	}

	.tipsList2 {
		background-color: #FFF1DF;
		color: #FE9229;
	}

	.tipsList3 {
		background-color: #E6FFE5;
		color: #08C800;
		padding: 13rpx 20rpx;
	}

	.tipsList4 {
		background-color: #FFEFEF;
		color: #EF312E;
	}

	.report-content-butList {
		border-top: 2rpx solid #E2E2E2;
		justify-content: space-around;

		.ff-align-items-1 {
			justify-content: center;
			padding: 30rpx;
			width: 50%;
			color: #3178FF;

			image {
				width: 28rpx;
				height: 30rpx;
				margin-right: 8rpx;
			}
		}

		.ff-align-items-1:nth-child(1) {
			border-right: 2rpx solid #E2E2E2;
		}
	}

	.signatureBox {
		width: 100%;
		height: 100%;

		&-title {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
		}

		&-content {
			padding: 95rpx 0 50rpx;

			image {
				width: 100rpx;
				height: 100rpx;
			}
		}
	}

	/deep/ .u-drawer-bottom {
		background-color: #f5f5f5 !important;
	}

	.unitDetails-btn {
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 10;
		width: 100%;
		background: transparent;

		&-box {
			width: 90%;
			margin: 5% 5% 4% 5%;
			background-color: #2979ff;
			color: #ffffff;
			padding: 20rpx;
			border-radius: 60rpx;
			text-align: center;
		}
	}

	.ff-color-B8DDFF {
		color: #B8DDFF;
	}
</style>